package cn.datawin.bms.modules.provider.service.impl;

import cn.datawin.bms.modules.provider.mapper.ProvProviderParamMapper;
import cn.datawin.bms.modules.provider.service.ProvProviderParamService;
import cn.datawin.bms.provider.entity.ProvProviderParamEntity;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 供应商接入参数表
 *
 * @author datawin-sms
 * @date 2025-08-21 11:29:41
 */
@Service
public class ProvProviderParamServiceImpl extends ServiceImpl<ProvProviderParamMapper, ProvProviderParamEntity> implements ProvProviderParamService {
    @Override
    public Map<String, String> getParams(Long providerId) {

		List<ProvProviderParamEntity> provProviderParamEntities = baseMapper.selectList(new LambdaQueryWrapper<ProvProviderParamEntity>()
				.eq(ProvProviderParamEntity::getProviderId, providerId));
		if(CollUtil.isEmpty(provProviderParamEntities)){
			return Collections.emptyMap();
		}

		return provProviderParamEntities.stream().collect(Collectors.toMap(ProvProviderParamEntity::getFieldName,ProvProviderParamEntity::getFieldValue));
    }
}
